class ElectriciansController < ApplicationController
  # GET /electricians
  # GET /electricians.json
  def index
    @electricians = Electrician.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @electricians }
    end
  end

  # GET /electricians/1
  # GET /electricians/1.json
  def show
    @electrician = Electrician.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @electrician }
    end
  end

  # GET /electricians/new
  # GET /electricians/new.json
  def new
    @electrician = Electrician.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @electrician }
    end
  end

  # GET /electricians/1/edit
  def edit
    @electrician = Electrician.find(params[:id])
  end

  # POST /electricians
  # POST /electricians.json
  def create
    @electrician = Electrician.new(params[:electrician])

    respond_to do |format|
      if @electrician.save
        format.html { redirect_to @electrician, notice: 'Electrician was successfully created.' }
        format.json { render json: @electrician, status: :created, location: @electrician }
      else
        format.html { render action: "new" }
        format.json { render json: @electrician.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /electricians/1
  # PUT /electricians/1.json
  def update
    @electrician = Electrician.find(params[:id])

    respond_to do |format|
      if @electrician.update_attributes(params[:electrician])
        format.html { redirect_to @electrician, notice: 'Electrician was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @electrician.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /electricians/1
  # DELETE /electricians/1.json
  def destroy
    @electrician = Electrician.find(params[:id])
    @electrician.destroy

    respond_to do |format|
      format.html { redirect_to electricians_url }
      format.json { head :no_content }
    end
  end
end
